package com.cardrive.entity;

import java.util.Vector;

public class GearBox {

	private int shift;
	private int numShifts;
	private double force;
	private boolean isBackwards;
	private boolean isNeutral;

	private Vector<Integer> shiftFactor;

	public GearBox(int numShifts) {

		this.numShifts = numShifts;

		shiftFactor = new Vector<Integer>();

		generateFactors(this.numShifts);
		
		force = 15;

	}

	public double getEngineForce() {
		double factor;
		if (isBackwards) {
			factor = -1;
		} else if (isNeutral) {
			factor = 0;
		} else {
			factor = shiftFactor.get(shift);
		}
		// return factor;
		return force * factor;
	}

	public void generateFactors(int numShifts) {

		shiftFactor.removeAllElements();
		for (int i = 0; i < numShifts; i++) {
			shiftFactor.add(i + 1);
		}
	}

	public int getShift() {
		return shift;
	}

	public void setShift(int shift) {
		this.shift = shift;
	}

}
